package com.cn.zy.zheda.demo.controller;

import com.cn.zy.zheda.demo.controller.request.UserReq;
import com.cn.zy.zheda.demo.service.UrlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author zhangyi
 * @date 2018/12/19 13:48
 */
@RestController
@Deprecated
public class BaseController {

    @Autowired
    UrlService urlService;

    @ModelAttribute
    public String getToken(){
        UserReq user = new UserReq("tenant@thingsboard.org","Tenant2018");
        String token = urlService.login(user);
        if(Objects.isNull(token)){
            try {
                throw new Exception("无法获取");
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }else{
            return token;
        }
    }
}
